<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增外派属性')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-setting-add" th:object="${staffingSetting}">
            <div class="form-group" th:hidden="true">
                <label class="col-sm-3 control-label is-required">对应id：</label>
                <div class="col-sm-8">
                    <input name="resourceId" class="form-control" type="hidden" th:field="*{resourceId}" >
                    <input name="resourceType" class="form-control" type="hidden" th:field="*{resourceType}" >
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">报价方式：</label>
                <div class="col-sm-8">
                    <select name="quotationType" id="quotationType" class="form-control m-b" th:with="type=${@dict.getType('quotation_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group" th:hidden="${staffingSetting.resourceType} != 'person'">
                <label class="col-sm-3 control-label">报价：</label>
                <div class="col-sm-8">
                    <input name="quotation" id="quotation" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group"  th:hidden="${staffingSetting.resourceType} != 'person'">
                <label class="col-sm-3 control-label">月报价：</label>
                <div class="col-sm-8">
                    <input name="quotationMonth" id="quotationMonth" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group"  th:hidden="${staffingSetting.resourceType} != 'person'">
                <label class="col-sm-3 control-label">日报价：</label>
                <div class="col-sm-8">
                    <input name="quotationDay" id="quotationDay" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">假期规则：</label>
                <div class="col-sm-8">
                    <select name="holidayConfigType" class="form-control m-b" th:with="type=${@customDictService.selectDictHolidayConfigType()}">
                        <option value="">无</option>
                        <option th:each="dict : ${type}" th:text="${dict.title}" th:value="${dict.id}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">缺勤规则：</label>
                <div class="col-sm-8">
                    <select name="absentType" class="form-control m-b" th:with="type=${@dict.getType('absent_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结算方式：</label>
                <div class="col-sm-8">
                    <select name="billType" class="form-control m-b" th:with="type=${@dict.getType('bill_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">加班单价规则：</label>
                <div class="col-sm-8">
                    <select name="overtimeType" class="form-control m-b" th:with="type=${@dict.getType('overtime_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">有效收款时间(月)：</label>
                <div class="col-sm-8">
                    <input name="billExpireMonth" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">报销结算比列(%)：</label>
                <div class="col-sm-8">
                    <input name="expenseRate" class="form-control" type="text" th:field="*{expenseRate}">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">税率(%)：</label>
                <div class="col-sm-8">
                    <input name="tax" class="form-control" type="text" th:field="*{tax}">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">账期费率(%)：</label>
                <div class="col-sm-8">
                    <input name="billFeeRate" class="form-control" type="text" th:field="*{billFeeRate}">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">账期：</label>
                <div class="col-sm-8">
                    <input name="billDays" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "staffing/setting"
        $("#form-setting-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-setting-add').serialize());
            }
        }
        function calculatQuotaion(){
            var quotationType = $('#quotationType').val();
            var quotaion = $('#quotation').val();
            switch (quotationType)
            {
                case 'M':
                    $('#quotationMonth').val(quotaion);
                    $('#quotationDay').val(parseFloat(quotaion/21.75).toFixed(2));
                    break;
                case 'D':
                    $('#quotationMonth').val(quotaion*21.75);
                    $('#quotationDay').val(quotaion);
                    break;
                case 'H':
                    $('#quotationMonth').val(quotaion*21.75*8);
                    $('#quotationDay').val(quotaion*8);
                    break;
                default:

            }
        }
        $(function (){
            $('#quotationType').change(function (){
                calculatQuotaion();
            });
            $('#quotation').blur(function (){
                calculatQuotaion();
            });
        });
        calculatQuotaion();
    </script>
</body>
</html>